<?php

namespace Platform\Services\Admin;

use Platform\Services\BaseService;

class RoleService extends BaseService {

    /**
     * 添加角色
     * @param $role
     * @return mixed
     */
    public function addRole($name,$role){
        $adminRole = model("Admin/AdminRole");
        $roleIsExit = $adminRole->getRoleByRemarkAndName($name,$role);
        if($roleIsExit){
            E("此角色已存在");
        }else{
            $adminRole->addRole($name,$role);
        }
    }


    /**
     * 查询所有角色
     */
    public function getAllRole(){
        $roleModel = model("Admin/AdminRole");
        $allRole = $roleModel->getRoleAll();
        return $allRole;
    }


    /**
     * 通过角色描述查询ID
     * @param $remark
     */
    public function getRoleIdByRemark($remark){
        $roleId = model("Admin/AdminRole")->getRoleIdByRemark($remark);
        return $roleId;
    }



}